//
//  CHBaseViewCell.m
//  CarFile
//
//  Created by 陈浩 on 2017/4/5.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHBaseViewCell.h"
@interface CHBaseViewCell ()

@property (nonatomic ,strong) NSArray *datas;


@end
@implementation CHBaseViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+(instancetype)cellForTableView:(UITableView *)tableView{
    
    static NSString *ID = @"CHBaseViewCell";
    CHBaseViewCell *cell = [[CHBaseViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    return cell;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
//        [self setUI];
        
    }
    return self;
}

//
//-(void)setUI{
//    
//   
//    _datas = @[@"市辖区",@"41",@"3",@"66.67%"];
//    
//    CGFloat margin = 10.0;
//    
//    CGFloat width = ( UIScreenW - 20  - 60 ) /_datas.count;
//    for (int i = 0; i < _datas.count; i++) {
//        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(margin + i *(width +20), 0, width, 44)];
//        label.font = [UIFont systemFontOfSize:12];
//        label.textAlignment = NSTextAlignmentCenter;
//        label .textColor = [UIColor colorWithHexString:@"333333" alpha:1.0f];
//        label.text = _datas[i];
//        if (i == _datas.count - 1) {
//            label.textColor = [UIColor colorWithHexString:@"ff3968" alpha:1.0f];
//        }
//        [self.contentView addSubview:label];
//    }
//    
//}

-(void)setModel:(DJ_Model *)model{
    _model = model;
    if (self.index == 0 || self.index == 2) {
       _datas = @[model.areacn,model.comnum,model.dockcomnum,model.dockcomrate];
    }else if (self.index == 1){
        int noupload = [model.comnum intValue] - [model.uploadnum intValue];
        NSString *nouploadnum = [NSString stringWithFormat:@"%d",noupload];
       _datas = @[model.areacn,model.comnum,model.uploadnum,nouploadnum,model.uploadrate];
    }
    
    
    CGFloat margin = 5.0;
    
    CGFloat width = ( UIScreenW - 30 ) /_datas.count;
    for (int i = 0; i < _datas.count; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(margin + i *(width +margin), 0, width, 44)];
        label.font = [UIFont systemFontOfSize:12];
        label.textAlignment = NSTextAlignmentCenter;
        label .textColor = [UIColor colorWithHexString:@"333333" alpha:1.0f];
        label.text = _datas[i];
        if (i == _datas.count - 1) {
            label.textColor = [UIColor colorWithHexString:@"ff3968" alpha:1.0f];
        }
        [self.contentView addSubview:label];
    }
    
    
    
}


@end
